package com.fusuhai.service.imp;

import com.fusuhai.bean.InsectBean;
import com.fusuhai.bean.UserBean;
import com.fusuhai.dao.InsectDao;
import com.fusuhai.service.InsectService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class InsectServiceImp implements InsectService {
    @Resource
    private InsectDao insectDao;

    @Override
    public void addInsect(InsectBean insect) {
        insectDao.addInsect(insect);
    }

    @Override
    public InsectBean selectInsect(int id) {
       return insectDao.selectInsect(id);
    }

    @Override
    public PageInfo<InsectBean> selectInsectByName(int pageNO, int pageSize,String name, String host) {
        PageHelper.startPage(pageNO, pageSize);
        PageInfo<InsectBean> pageInfo=PageInfo.of(insectDao.selectInsectByName(name,host));
        return pageInfo;
    }

    @Override
    public PageInfo<InsectBean> selectAllInsect(int pageNO, int pageSize) {
        PageHelper.startPage(pageNO, pageSize);
        PageInfo<InsectBean> pageInfo=PageInfo.of(insectDao.selectAllInsect());
        return pageInfo;
    }
}
